export default {
  namespaced: true,
  state: () => ({
    name: '张智琦',
    age: 18
  }),
  getters: {
    userInfo(state) {
      return `姓名：${state.name} 年龄：${state.age}`
    }
  },
  mutations: {
    setName(state, name) {
      state.name = name
    },
    increaseAge(state) {
      state.age++
    }
  },
  actions: {
    setNameAsync(context, name) {
      setTimeout(() => {
        context.commit('setName', name)
      }, 1000)
    },
    increaseAgeAsync(context) {
      setTimeout(() => {
        context.commit('increaseAge')
      }, 1000)
    }
  }
}
